const express = require('express')
const path = require('path')
const router = require('./router')
const session = require('express-session')

const app = express()
//配置art-tempalte
app.engine('html',require('express-art-template'))
//开放静态资源
app.use('/node_modules',express.static(path.join(__dirname,'node_modules')))
app.use('/public',express.static(path.join(__dirname,'public')))
//配置获取body
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
//配置session
app.use(session({
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: true
  }))
//挂载路由
app.use(router)

app.use(function(req,res,err){
    return res.status(500).json({
        err_code:500,
        msg:'sever error'
    })
})
app.listen(3000,function(){
    console.log('running...')
})